/**
 * @Author: lclangcheng
 * @Date:   2018-08-17 10:04:13
 * @Email:  lclangcheng@gmail.com
 * @Filename: cors.js
 * @Last modified by:   lclangcheng
 * @Last modified time: 2018-08-27 11:24:44
 * @License: jin10
 * @Copyright: jin10
 */
'use strict'

const cors = require('koa2-cors')

module.exports = cors({
  origin: function (ctx) {
    return ctx.get('Origin') || '*'
  },
  maxAge: 86400,
  credentials: true,
  allowMethods: ['GET', 'POST', 'DELETE', 'PUT', 'OPTIONS'],
  allowHeaders: ['Content-Type', 'Authorization', 'Accept', 'X-Requested-With', 'X-Xsrf-Token']
})
